package com.rt.tmpt.service;

import com.googlecode.genericdao.search.Search;
import com.rt.easyjava.base.biz1.bean.TmptData;
import com.rt.tmpt.bean.A1TemplateTable;
import com.rt.tmpt.dto.*;
import org.hibernate.HibernateException;
import org.json.JSONObject;
import org.springframework.data.domain.Example;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

public interface ITemplateService {
	public Result paginationBySearch(Map<String, String[]> parameterMap, PageDto pageDto);
	public Result paginationBySearch4DynamicDS(A1TemplateTable templateTable, Map<String, String[]> paramMap1, String paramJson,
                                               String _historyId, Map<String, Object> paramMap) throws Exception;

	public A1TemplateTableDto getTemplateTable(String keyRandom);
	//public Map<String, Object> getConditionMultiQuery(String keyRandom);

	public List<Map<String,Object>> queryReportBySearch(A1TemplateTableDto templateTableDto, String reportSqlString, List<Object> paramList);



	public Result addA1TemplateTable(A1TemplateTableDto a1TemplateTableDto);
	public Result addA1TemplateColumn2Table(A1TemplateColumnDto a1TemplateColumnDto, long tableId);



	public PaginationDto<A1TemplateTableDto> paginationA1TemplateTableListBySearch(Search search);
	public PaginationDto<A1TemplateColumnDto> paginationA1TemplateColumnListBySearch(Search search);

	/**
	 * 添加数据
	 * @param keydom
	 * @param jsonParam
	 * @return
	 */
	public Result addData(String keydom, String jsonParam) throws HibernateException, SQLException;

	/**
	 * 根据数据源执行addData
	 * @param a1TemplateTable
	 * @param json
	 * @param columnList
	 * @return
	 * @throws Exception
	 */
	public Result addData4DynamicDS(A1TemplateTable a1TemplateTable, JSONObject json, List<Map<String, Object>> columnList) throws Exception;

	/**
	 * 编辑数据
	 * @param keydom
	 * @param jsonParam
	 * @param id
	 * @return
	 */
	public Result editData(String keydom, String id, String jsonParam) throws HibernateException, SQLException;

	/**
	 * 根据数据源执行editData
	 * @param a1TemplateTable
	 * @param id
	 * @param json
	 * @param columnList
	 * @return
	 * @throws Exception
	 */
	public Result editData4DynamicDS(A1TemplateTable a1TemplateTable, String id, JSONObject json, List<Map<String, Object>> columnList) throws Exception;

	/**
	 * 伪删除
	 * @param parameters
	 * @return
	 */
	public Result removeData(String... parameters);

	/**
	 * 多值选择，key-value形式; case status when 1 then '有效' when 0 then '无效' end
	 * @param keyRandom
	 * @return
	 */
	public String getTemplateTableColumnOptionJson(String keyRandom);

	/**
	 * 多值选择，key-value形式; case status when 1 then '有效' when 0 then '无效' end
	 * @param keyRandom
	 * @return
	 */
	public List<A1TemplateColumnDto> getTemplateTableColumnOptionList(String keyRandom);

	/**
	 * 自动加载模板列
	 * @param _id
	 * @return
	 */
	public Result loadColumn(String _id);

	/**
	 * 自动加载模板列(By a1TemplateTable datasource)
	 * @param templateTable
	 * @param tempColList
	 * @return
	 */
	public Result loadColumn4DynamicDS(A1TemplateTable templateTable, List<String> tempColList);

	/**
	 * 生成sql语句
	 * @return
	 * @throws Exception
	 */
	public Result genSql4DynamicDS(String paramJson) throws Exception;



	/**
	 * 查询option数据字典列表
	 * @param example
	 * @return
	 */
	public List<A1TemplateColumnOptionDataDto> queryOptionDataListBySearch(Example example);

	/**
	 * 扫库自动配置生成源码
	 * @param mistTablename
	 * @return
	 */
	public Result autocodebuilder(String mistTablename);

	/**
	 * 数据字典
	 * @param id
	 * @return
	 */
	public TmptData queryTmptDataById(Long id);
}
